package com.scwatch.core.domain;


import javax.persistence.*;
import java.util.Date;

/**
 * Created by rh006 on 2017/7/27.
 */

@Entity
@Table(name = "cms_program_content")
public class ProgramBackcode implements java.io.Serializable{





    private Integer id;
    //内容
    private String name;
    //关键词
    private String mainword;
    private Date time;
    private User user;

    private String videoTime;
    //外键id
//    private  Integer did;
    private String video;
    private String videoName;
    private Long videoLength;
//    private String updatetime;
    private String vidioresuoce;
    private String smallImage;
//    private String programName;
    private ProgramDatecheack  programDatecheack;
//    private String  pname;

    @Id
    @Column(name = "p_pid", unique = true, nullable = false)
    @TableGenerator(name = "tg_cms_program_content", pkColumnValue = "cms_program_content", initialValue = 1, allocationSize = 10)
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "tg_cms_program_content")
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }



    @Column(name = "p_content", nullable = false, length = 100)
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }



    @Column(name = "p_mainwordname", nullable = false, length = 255)
    public String getMainword() {
        return this.mainword;
    }

    public void setMainword(String mainword) {
        this.mainword = mainword;
    }




    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "p_user_id", nullable = false)
    public User getUser() {
        return user;
    }
    public void setUser(User user) {
        this.user = user;
    }




    @Column(name = "p_publishtime", nullable = false, length = 100)
    public Date getTime() {
        return this.time;
    }
    public void setTime(Date time) {
        this.time = time;
    }

    @Column(name = "p_vadiotime", nullable = false, length = 100)
    public String getVideoTime() {
        return videoTime;
    }

    public void setVideoTime(String videoTime) {
        this.videoTime = videoTime;
    }


//
//    @Column(name = "d_id", nullable = false, length = 11)
//    public Integer getDid() {
//        return this.did;
//    }
//
//    public void setDid(Integer did) {
//        this.did = did;
//    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "d_id", referencedColumnName = "d_id", nullable = false)
    public ProgramDatecheack getProgramDatecheack() {
        return programDatecheack;
    }

    public void setProgramDatecheack(ProgramDatecheack programDatecheack) {
        this.programDatecheack = programDatecheack;
    }
    @Column(name = "p_videourl", nullable = true, length = 100)
    public String getVideo() {
        return video;
    }

    public void setVideo(String video) {
        this.video = video;
    }

    @Column(name = "p_videoname", nullable = true, length = 100)
    public String getVideoName() {
        return videoName;
    }

    public void setVideoName(String videoName) {
        this.videoName = videoName;
    }

    @Column(name = "p_videolength", nullable = true, length = 20)
    public Long getVideoLength() {
        return videoLength;
    }

    public void setVideoLength(Long videoLength) {
        this.videoLength = videoLength;
    }

    //
//    @Column(name = "p_uploadtime", nullable = false, length = 100)
//    public String getUpdatetime() {
//        return updatetime;
//    }
//    public void setUpdatetime(String updatetime) {
//        this.updatetime = updatetime;
//    }
    @Column(name = "p_videoresuoce", nullable = false, length = 100)
    public String getVidioresuoce() {
        return vidioresuoce;
    }

    public void setVidioresuoce(String vidioresuoce) {
        this.vidioresuoce = vidioresuoce;
    }
    @Column(name = "p_small_imge", nullable = false, length = 225)
    public String getSmallImage() {
        return smallImage;
    }

    public void setSmallImage(String smallImage) {
        this.smallImage = smallImage;
    }

    //    @Column(name = "p_f_hotword_name", nullable = false, length = 255)
//    public String getProgramName() {
//        return programName;
//    }
//
//    public void setProgramName(String programName) {
//        this.programName = programName;
//    }
//    @Column(name = "p_program_name", nullable = true, length = 255)
//    public String getPname() {
//        return pname;
//    }
//
//    public void setPname(String pname) {
//        this.pname = pname;
//    }
    @Transient
    public String getPlayNum(){
      Long num=getProgramDatecheack().getProgramback().getPlaynum();
//      BigDecimal b=new BigDecimal(num==null?0:num);
//      BigDecimal result=b.divide(new BigDecimal(10000),0,BigDecimal.ROUND_HALF_UP);
        String str="0";
        if(num!=null){
             str=num.toString();
        }
        return  str;
    }

    @Transient
    public String getPlayNumStr(){
        Long num=getProgramDatecheack().getProgramback().getPlaynum();
//        BigDecimal b=new BigDecimal(num==null?0:num);
//        BigDecimal result=b.divide(new BigDecimal(10000),0,BigDecimal.ROUND_HALF_UP);
//        String r=result.toString();
        String str="0";
        if(num!=null){
            str=num.toString();
        }
        return  str;
    }
}
